<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>我的微讯</title>
<link type="image/x-icon" rel="Shortcut Icon"
	href="<%=basePath%><%=basePath%>Images/favicon.ico" />
<style type="text/css">
@import "<%=basePath%>CSS/Yiian_Style.css";
</style>
<link type="text/css" rel="stylesheet"
	href="<%=basePath%>CSS/Yiian_Include.css" />
<link type="text/css" rel="stylesheet"
	href="<%=basePath%>CSS/Yiian_MicroNews.css" />
<link type="text/css" rel="stylesheet"
	href="<%=basePath%>CSS/common/back.css" />
<script type="text/javascript" language="javascript"
	src="<%=basePath%>JS/jquery-1.6.2.min.js"></script>
<script type="text/javascript">


	function showReview(_msgid){
		$("#review_"+ _msgid).slideToggle("slow");
	}

	function submitReview(_msgid){
		
		var params = {};
		params["message.pid"] = _msgid;
		params["message.content"] = $("#textarea_" + _msgid ).val();
		$.ajax({
			type : "post",
			url : "<%=basePath%>message/addBack.action",
			dataType : "json",
			data : params ,
			success : function(_result) {
				if("true" == _result.success){
					var data  = _result.data[0];
					var backDiv = $("#backTemplate").clone();
					backDiv.attr("id", _result.msgid);
					var textInfo = backDiv.find("div").filter(".txtinfo");
					textInfo.find("a:eq(0)").html(data.user.username).end().find("font").html(data.content).end().find("span").filter(".MIB_txtbl").html("(" + data.publishtime + ")");
					backDiv.prependTo("#ul_" + _msgid);
					backDiv.slideDown("slow");

					$("#textarea_" + _msgid ).val("");
						
				}
				
			},
			error:function(){
				alert("网络链接异常！");
				return false;
			}
		});
	
	}


	function test(){

		var xunxinDiv = $("#xunxiTemplate").clone();
		xunxinDiv.attr("id", "12121212");

		var contentDiv_0 = xunxinDiv.find("div:eq(0)");
		var contentDiv_1 = xunxinDiv.find("div:eq(1)");

		contentDiv_0.find("img").attr("src","<%=basePath%>upload/showImage.jsp?path=");

		contentDiv_1.find("font:eq(0)").html("内容")
					.end()
					.find("span:eq(0)").html("用户名")
					.end()
					.find("span:eq(1)").find("font:eq(0)").html("时间");
					
					
		
		xunxinDiv.prependTo("#info1");
		xunxinDiv.slideDown("slow");

		var reviewDiv = $("#reviewTemplate").clone();
		reviewDiv.attr("id", "review_12121212");
		reviewDiv.find("a").filter(".btn_normal").attr("href" ,"javascript:submitReview('" + 12121212 +"')");
		xunxinDiv.find("span").filter(".shoucang").find("a:eq(1)").attr("href", "javascript:showReview('" + 12121212 +"')");
		reviewDiv.find("textarea").attr("id", "textarea_" + "12121212").end().find("ul").filter(".PL_list").attr("id","ul_" + "12121212");
		xunxinDiv.after(reviewDiv);

		//javascript:showReview('${item.msgid}'); javascript:submitReview('item.msgid');
	}
	var userId = ${sessionScope.user.userid} || false;

	//如果用户存在，轮询开始
	if(userId){
		loopRquest();
	}

	function loopRquest() {
		setTimeout(function() {
			$.ajax({
				type : "post",
				url : "<%=basePath%>mess/getAjaxData",
				dataType : "json",
				data : {"user.userid" : userId} ,
				success : function(_result) {
					if("true" == _result.success ){
						for(var index=0; index < _result.data.length ; index++){
							var result = _result.data[index];
							var msgid = result.msgid;
							var xunxinDiv = $("#xunxiTemplate").clone();
							xunxinDiv.attr("id", msgid);

							var contentDiv_0 = xunxinDiv.find("div:eq(0)");
							var contentDiv_1 = xunxinDiv.find("div:eq(1)");

							contentDiv_0.find("img").attr("src","<%=basePath%>upload/showImage.jsp?path=" + result.weixun.logo);

							contentDiv_1.find("font:eq(0)").html(result.content)
										.end()
										.find("span:eq(0)").html(result.weixun.name)
										.end()
										.find("span:eq(1)").find("font:eq(0)").html(result.publishtime);
										
										
							
							xunxinDiv.prependTo("#info1");
							xunxinDiv.slideDown("slow");


							var reviewDiv = $("#reviewTemplate").clone();
							reviewDiv.attr("id", "review_" + msgid);
							reviewDiv.find("a").filter(".btn_normal").attr("href" ,"javascript:submitReview('" + msgid +"')");
							reviewDiv.find("textarea").attr("id", "textarea_" + msgid).end().find("ul").filter(".PL_list").attr("id","ul_" + msgid);
							xunxinDiv.find("span").filter(".shoucang").find("a:eq(1)").attr("href", "javascript:showReview('" + msgid +"')");
							xunxinDiv.after(reviewDiv);
						}
					}
					
					//递归调用
					loopRquest();
				},
				error:function(){
					alert("网络链接异常！");
					return false;
				}
			});
		}, 9000);
	}
</script>
</head>
<body>
<div class="homeheader header">
  <div class="logo"><a href="http://www.wixun.com" title="微讯"><img
	src="<%=basePath%>Images/Logo.png" /></a></div>
  <form action="searches.php" class="" id="" method="post" name="soso">
    <ul class="tool">
      <li class="search"><span class="bai">${sessionScope.user.username }</span>&nbsp;&nbsp;&nbsp;|<a
		class="nav" href="Tools.html">应用工具</a>|<a class="nav"
		href="<%=basePath%>Notice.html">我的私信(<span style="color: #FC0">12</span>)</a>|<a
		class="nav" href="Private.html">账户设置</a>|<a style="padding-right: 0;"
		class="nav" href="index.html">退出登录</a></li>
      <li style="padding-top: 9px; height: 21px;" class="search">
        <input
		type="text" class="sotxt txt" id="" name="" value="输入关键字搜索微讯" />
        <input
		type="submit" class="sobtn" id="" name="" value="搜索" onClick="soso();" />
      </li>
    </ul>
  </form>
</div>
<div class="homemain">
  <div class="homeleft">
    <div class="adpic"><a href="#"><img
	src="<%=basePath%>Pictures/adpic.jpg" /></a> <span class="number"><a
	class="shu" href="javascript:test();">1</a><a class="shu" href="#">2</a><a class="shu"
	href="#">3</a><a class="shu" href="#">4</a></span></div>
    <div class="biaoqiao"><span class="xuanxiang" id="xuan2">最新讯息</span> </div>
    <div class="info" id="info1">
      <div class="bobao" id="xunxiTemplate" style="display: none;">
        <div class="bobaoico"><a href="" target="_blank"><img
		class="icopic" src="" /></a> </div>
        <div class="bobaoinfo"><span class="blue"></span>&nbsp;&nbsp;<font></font><br />
          <span class="blue"> <font></font>&nbsp;&nbsp;&nbsp; <font class="hui">来自</font> 网页 </span> <span class="shoucang"><a
			class="pinglun blue" href="#">收藏</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a
			class="pinglun blue" href="#">评论</a> </span> </div>
        <div style="clear: both; height: 10px; font-size: 0;"></div>
      </div>
      <div class="MIB_assign rt" style="display:none;" id="reviewTemplate">
        <div class="MIB_asarrow_r"> </div>
        <div class="MIB_assign_t"> </div>
        <div class="MIB_assign_c MIB_txtbl">
          <div class="logininput new_position"> <a onClick=""
	      class="faceicon1" href="javascript:void(0);" title="表情"> </a>
            <textarea class="lf" style="overflow: hidden; height: 18px; font-family: Tahoma,宋体; border-style: solid; border-width: 1px; word-wrap: break-word; font-size: 12px; line-height: 18px;"
	      id="textarea_msgid"></textarea>
            <a href="javascript:submitReview('item.msgid');"
	      class="btn_normal"> <em> 评论 </em> </a>
            <div class="margin_b MIB_txtbl ml35">
              <p>
                <input type="checkbox" />
                <label> 同时转发到我的微博 </label>
              </p>
            </div>
          </div>
          <ul class="PL_list oddline" id="">
          </ul>
          <div class="list_head MIB_linedot3 moreheight"> 后面还有 <span> 0 </span> 条评论， <a href="#"> 点击查看 <em> &gt;&gt; </em> </a> </div>
        </div>
      </div>
      <li class="MIB_linedot3" style="display:none;" id="backTemplate"> <a href="#"> <img class="picborder_l lf" src="<%=basePath%>upload/showImage.jsp?path="
    title=""> </a>
        <div class="txt">
          <div class="txtinfo"> <a href="#"> </a> <font></font> <span class="MIB_txtbl" type="time"> </span> </div>
          <p class="MIB_more MIB_linkbl"> <a style="visibility: hidden;" class="reportBtn"> 举报 </a> <span style="visibility: hidden;" class="MIB_line_l"> | </span> <a class="lose" href="#"> 回复 </a> </p>
        </div>
        <span class="clear"> </span> </li>
      <!-- 循环内容 -->
      <c:forEach var="item" items="${msgList}">
        <div class="bobao">
          <div class="bobaoico"><a href=""
			target="_blank"><img class="icopic"
			src="<%=basePath%>upload/showImage.jsp?path=${item.weixun.logo}" /></a></div>
          <div class="bobaoinfo"><span class="blue">${item.weixun.name }&nbsp;&nbsp;</span>${item.content}<br />
            <span class="blue">
            <fmt:formatDate value="${item.publishtime}" pattern="MM月dd日     HH:mm" />
            &nbsp;&nbsp;&nbsp; <font class="hui">来自</font>网页</span> <span class="shoucang"><a
			class="pinglun blue" href="#">收藏</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a
			class="pinglun blue" href="javascript:showReview('${item.msgid}');" name="review">评论(${fn:length(item.backMsgList)})</a></span></div>
          <div style="clear: both; height: 10px; font-size: 0;"></div>
        </div>
        <div class="MIB_assign rt" style="display:none;" id="review_${item.msgid }">
          <div class="MIB_asarrow_r"> </div>
          <div class="MIB_assign_t"> </div>
          <div class="MIB_assign_c MIB_txtbl">
            <div class="logininput new_position"> <a onClick=""
	      class="faceicon1" href="javascript:void(0);" title="表情"> </a>
              <textarea class="lf" style="overflow: hidden; height: 18px; font-family: Tahoma,宋体; border-style: solid; border-width: 1px; word-wrap: break-word; font-size: 12px; line-height: 18px;"
	      id="textarea_${item.msgid}"></textarea>
              <a href="javascript:submitReview('${item.msgid}');" id=""
	      class="btn_normal"> <em> 评论 </em> </a>
              <div class="margin_b MIB_txtbl ml35">
                <p>
                  <input type="checkbox" />
                  <label> 同时转发到我的微博 </label>
                </p>
              </div>
            </div>
            <ul class="PL_list oddline" id="ul_${item.msgid}">
              <c:forEach var="backitem" items="${item.backMsgList}">
                <li class="MIB_linedot3"> <a href="#"> <img class="picborder_l lf" src="<%=basePath%>upload/showImage.jsp?path="
		          title="${ backitem.user.username}"> </a>
                  <div class="txt">
                    <div class="txtinfo"> <a href="#"> ${ backitem.user.username} </a> ${backitem.content } <span class="MIB_txtbl"> (
                      <fmt:formatDate value="${backitem.publishtime}" pattern="MM月dd日     HH:mm" />
                      ) </span> </div>
                    <p class="MIB_more MIB_linkbl"> <a style="visibility: hidden;" class="reportBtn"> 举报 </a> <span style="visibility: hidden;" class="MIB_line_l"> | </span> <a class="lose" href="#"> 回复 </a> </p>
                  </div>
                  <span class="clear"> </span> </li>
              </c:forEach>
            </ul>
            <div class="list_head MIB_linedot3 moreheight"> 后面还有 <span> 0 </span> 条评论， <a href="#"> 点击查看 <em> &gt;&gt; </em> </a> </div>
          </div>
        </div>
      </c:forEach>
      <!-- 循环内容结束 -->
      <div class="page"><span class="fenyishou fenyi">1</span><a
	class="fenyi" href="#">2</a><a class="fenyi" href="#">3</a><a
	class="fenyi" href="#">4</a><a class="fenyi" href="#">5</a><a
	class="fenyi" href="#">6</a>......<a class="fenyi" href="#">30</a><a
	class="fenyi" href="#">下一页</a></div>
    </div>
  </div>
  <div class="homeright"><img class="ico icopic"
	src="<%=basePath%>upload/showImage.jsp?path=${sessionScope.user.userpic}" />
    <div class="ziliao">
      <div class="wanzheng" style="width: 60px"></div>
      <span class="bili">60%</span></div>
    <h3 class="name">${sessionScope.user.username }</h3>
    <ul class="mywixun">
      <li class="menu1 menu"><a class="caidan" href="Private.html?id=">我的资料</a><span
		class="red">(60%)</span></li>
      <li class="menu2 menu"><a class="caidan" href="Notice.hmtl?id=">我的私信</a><span
		class="red">(12)</span></li>
      <li class="menu3 menu"><a class="caidan" href="Ggneral.html?id=">我的收藏</a><span
		class="red">(12)</span></li>
      <li class="menu4 menu"><a class="caidan" href="Members.html?id=">我关注的微讯</a><span
		class="red">(${fn:length(followingList)})</span></li>
      <li class="mywixun">
        <ul class="liebiao mywixun">
          <c:forEach var="item" items="${followingList}" varStatus="status">
            <li class="bu"></li>
            <li class="tuwen"><a
				href="<%=basePath%>${item.path }/weixun" target="_blank"><img
				class="icopic" src="<%=basePath%>upload/showImage.jsp?path=${item.logo}" /></a><a
				class="myname" href="<%=basePath%>${item.path }/weixun" target="_blank">${item.name} </a></li>
          </c:forEach>
          <li class="more"><a class="gengduo blue" href="#">更多<span
			class="songti">&nbsp;>></span></a></li>
        </ul>
      </li>
      <li class="menu4 menu"><span class="caidan" href="#">我创建的微讯</span></li>
      <li class="mywixun">
        <ul class="liebiao mywixun">
          <li class="chuanjian">欢迎加入微讯，赶快创建属于自己的微讯发布平台！</li>
          <c:set var="remindCount" value="0" />
          <c:forEach var="item" items="${createdWeixunList}" varStatus="status">
            <c:set var="remindCount" value="${status.count }" />
            <li class="bu"></li>
            <li class="tuwen"><a
				href="<%=basePath%>${item.path}/msg" target="_blank"><img
				class="icopic" src="<%=basePath%>upload/showImage.jsp?path=${item.logo}" /></a><a
				class="myname" href="<%=basePath%>${item.path}/msg" target="_blank">${item.name} </a></li>
          </c:forEach>
          <c:forEach var="x" begin="1" end="${3 - remindCount }" step="1">
            <li class="bu"></li>
            <li class="tuwen"><a href="<%=basePath%>Right/create.jsp" target="_blank"><img
				class="icopic" src="<%=basePath%>Images/icopic1.jpg" /></a><a
				class="myname" href="Create.html" target="_blank">创建</a></li>
          </c:forEach>
          <li style="clear: both; height: 0; font-size: 0;"></li>
        </ul>
      </li>
      <li class="menu4 menu"><a class="caidan" href="Members.html">我管理的微讯</a><span
		class="red">(${fn:length(createdWeixunList)})</span></li>
      <li class="mywixun">
        <ul class="liebiao mywixun">
          <c:forEach var="item" items="${createdWeixunList}" varStatus="status">
            <li class="bu"></li>
            <li class="tuwen"><a
				href="<%=basePath%>${item.path}/msg" target="_blank"><img
				class="icopic" src="<%=basePath%>upload/showImage.jsp?path=${item.logo}" /></a><a
				class="myname" href="<%=basePath%>${item.path}/msg"
				target="_blank">${item.name }</a></li>
          </c:forEach>
          <li style="clear: both; height: 0; font-size: 0;"></li>
        </ul>
      </li>
      <li class="menu4 menu"><a class="caidan" href="#">可能感兴趣的微讯</a><span
		class="red">(${fn:length(interestedList)})</span></li>
      <li class="mywixun">
        <ul class="liebiao mywixun">
          <c:forEach var="item" items="${interestedList}" varStatus="status">
            <li class="bu"></li>
            <li class="tuwen"><a
				href="<%=basePath%>${item.path }/weixun"
				target="_blank"><img class="icopic"
				src="<%=basePath%>upload/showImage.jsp?path=${item.logo}" /></a><a class="myname"
				href="<%=basePath%>${item.path }/weixun"
				target="_blank">${item.name}</a></li>
          </c:forEach>
          <li class="more"><a class="gengduo blue" href="#">更多<span
			class="songti">&nbsp;>></span></a></li>
        </ul>
      </li>
    </ul>
  </div>
  <div style="clear: both; height: 0; font-size: 0;"></div>
</div>
<div class="copyright"><a class="links" href="#" target="_blank">帮助信息</a>-<a
	class="links" href="#" target="_blank">联系我们</a>-<a class="links"
	href="#" target="_blank">意见建议</a>-<a class="links" href="#"
	target="_blank">举报</a>-<a class="links" href="index.html">微讯首页</a><br />
  Copyright&nbsp;&copy;&nbsp;2011&nbsp;&nbsp;Wixun.com&nbsp;&nbsp;Inc.&nbsp;&nbsp;All&nbsp;Rights&nbsp;Reserved.&nbsp;&nbsp;&nbsp;&nbsp;蛙扑公司&nbsp;&nbsp;&nbsp;&nbsp;版权所有 </div>
</body>
</html>
